<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/template.xhtml">
	<ui:define name="pageTitle">Menu principal</ui:define>
	<ui:define name="pageHeader">SisExercicio</ui:define>
	<ui:define name="body">
		<h:form id="form">
			<p:panel header="Buscar vendas" styleClass="painelBuscarVendas">
				<h:panelGrid columns="1">
					<h:panelGrid columns="3">
						<h:outputLabel value="Digite o ID da venda:" />
						<p:inputText value="#{beanVenda.vendaSelecionada.vendaId}" />
						<p:commandButton value="Buscar" action="#{beanVenda.buscarPorID}"
							update=":form:Listarvendas">
						</p:commandButton>
					</h:panelGrid>
					<p:dataTable id="Listarvendas" var="venda"
						value="#{beanVenda.listaVendas}"
						emptyMessage="Registro nao localizado" styleClass="colunaGrande">
						<p:column styleClass="colunaId">
							<f:facet name="header">Id</f:facet>
							#{venda.vendaId}
						</p:column>
						<p:column styleClass="colunaData">
							<f:facet name="header">Data</f:facet>
							<p:outputLabel value="#{venda.dataVenda}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</p:outputLabel>
						</p:column>
						<p:column styleClass="colunaNome">
							<f:facet name="header">Cliente</f:facet>
							#{venda.cliente.nome}
						</p:column>
						<p:column styleClass="colunaValor">
							<f:facet name="header">Valor total</f:facet>
							<p:outputLabel value="#{venda.valorTotal}">
								<f:convertNumber currencyCode="BRL" type="currency" />
							</p:outputLabel>
						</p:column>
						<p:column>
							<f:facet name="header">Status</f:facet>
							<p:outputLabel value="#{venda.flagVendaAtiva}" />
						</p:column>
						<p:column>
							<p:commandLink action="#{beanVenda.cancelarVenda}" ajax="false"
								onclick="if(!confirm('Deseja cancelar a venda?')) return false;">
								<h:graphicImage library="imagens" name="excluir.png" />
								<f:setPropertyActionListener
									target="#{beanVenda.vendaSelecionada}" value="#{venda}" />
							</p:commandLink>
						</p:column>
						<f:facet name="footer">
						</f:facet>
					</p:dataTable>
				</h:panelGrid>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>